<template>
  <div class="map-mgt">
    <div class="conditions-box ">
      <div class="left">
        <el-button size="mini"
          type="primary"
          @click="add"
          class="add">新增地图服务</el-button>
      </div>
      <div class="right">

        <el-form :model="queryParams"
          ref="queryForm"
          size="small"
          :inline="true">
          <el-form-item label="服务名称:"
            prop="configName">
            <el-input v-model="queryParams.name"
              placeholder="请输入服务名称名称"
              clearable
              style="width: 200px"
              @keyup.enter.native="handleQuery" />
          </el-form-item>
          <el-form-item label="服务类别:"
            prop="configType">
            <el-select v-model="queryParams.configType"
              placeholder="请选择服务类别"
              clearable>
              <el-option v-for="dict in dictOpt"
                :key="dict.value"
                :label="dict.label"
                :value="dict.value" />
            </el-select>
          </el-form-item>
          <el-form-item label="年份:">
            <el-date-picker v-model="dateRange"
              style="width: 240px"
              type="monthrange"
              range-separator="-"
              start-placeholder="开始年份"
              end-placeholder="结束年份"></el-date-picker>
          </el-form-item>
          <el-form-item>
            <el-button size="mini"
              type="primary"
              @click="search">查询</el-button>
            <el-button size="mini"
              type="primary"
              @click="resetClick(queryParams)">重置</el-button>
          </el-form-item>
        </el-form>
      </div>
    </div>
    <div class="tbl-box">
      <el-table :data="tableData"
        style="width: 100%"
        height="100%">
        <el-table-column prop="date"
          label="日期"
          width="180">
        </el-table-column>
        <el-table-column prop="name"
          label="姓名"
          width="180">
        </el-table-column>
        <el-table-column prop="address"
          label="地址">
        </el-table-column>
        <el-table-column label="操作"
          width="180"
          prop="operaton">
          <template slot-scope="scope">
            <el-button size="mini"
              type="text"
              icon="el-icon-edit"
              @click="handleEdit(scope.$index, scope.row)">编辑</el-button>
            <el-popover width="160"
              v-model="scope.row.popvisible">
              <p>确定删除吗？</p>
              <div style="text-align: right; margin: 0">
                <el-button size="mini"
                  type="text"
                  @click="scope.row.popvisible = false">取消</el-button>
                <el-button type="primary"
                  size="mini"
                  @click="handleDelete(scope.row)">确定</el-button>
              </div>
              <TextButton size="mini"
                color="danger"
                slot="reference"
                icon="el-icon-delete">删除</TextButton>
              <!-- <el-button class="popover-danger"
                size="mini"
                slot="reference"
                type="text"
                icon="el-icon-delete">删除</el-button> -->
            </el-popover>

          </template>
        </el-table-column>
      </el-table>
    </div>
    <div class="pag-wrapper">
      <el-pagination :layout="layout"
        :page-sizes="pageSizeOptions"
        :total="total"
        @size-change="pageSizeFun"
        @current-change="pageFun" />
    </div>
  </div>
</template>

<script>
  import listUrlParam from '@/utils/listUrlParam.js';
  import TextButton from '@/components/text-button/index.vue';
  const list = [
    {
      date: '2016-05-02',
      name: '王小虎',
      address: '上海市普陀区金沙江路 1518 弄'
    },
    {
      date: '2016-05-04',
      name: '王小虎',
      address: '上海市普陀区金沙江路 1517 弄'
    },
    {
      date: '2016-05-01',
      name: '王小虎',
      address: '上海市普陀区金沙江路 1519 弄'
    },
    {
      date: '2016-05-03',
      name: '王小虎',
      address: '上海市普陀区金沙江路 1516 弄'
    },
    {
      date: '2016-05-03',
      name: '王小虎',
      address: '上海市普陀区金沙江路 1516 弄'
    },
    {
      date: '2016-05-03',
      name: '王小虎',
      address: '上海市普陀区金沙江路 1516 弄'
    },
    {
      date: '2016-05-03',
      name: '王小虎',
      address: '上海市普陀区金沙江路 1516 弄'
    },
    {
      date: '2016-05-03',
      name: '王小虎',
      address: '上海市普陀区金沙江路 1516 弄'
    },
    {
      date: '2016-05-03',
      name: '王小虎',
      address: '上海市普陀区金沙江路 1516 弄'
    },
    {
      date: '2016-05-03',
      name: '王小虎',
      address: '上海市普陀区金沙江路 1516 弄'
    },
    {
      date: '2016-05-03',
      name: '王小虎',
      address: '上海市普陀区金沙江路 1516 弄'
    },
    {
      date: '2016-05-03',
      name: '王小虎',
      address: '上海市普陀区金沙江路 1516 弄'
    },
    {
      date: '2016-05-03',
      name: '王小虎',
      address: '上海市普陀区金沙江路 1516 弄'
    },
    {
      date: '2016-05-03',
      name: '王小虎',
      address: '上海市普陀区金沙江路 1516 弄'
    },
    {
      date: '2016-05-03',
      name: '王小虎',
      address: '上海市普陀区金沙江路 1516 弄'
    },
    {
      date: '2016-05-03',
      name: '王小虎',
      address: '上海市普陀区金沙江路 1516 弄'
    },
    {
      date: '2016-05-03',
      name: '王小虎',
      address: '上海市普陀区金沙江路 1516 弄'
    }
  ];
  export default {
    name: 'mapApi',
    mixins: [listUrlParam],
    components: {
      TextButton
    },
    data() {
      return {
        activeName: 'mgt',
        // 日期范围
        dateRange: [],
        queryParams: {
          name: '',
          configType: ''
        },
        dictOpt: [
          {
            label: '公开',
            value: 1
          },
          {
            label: '保密',
            value: 2
          }
        ],
        tableData: []
      };
    },
    created() {
      this.tableData = list.map((li) => {
        return {
          ...li,
          popvisible: false
        };
      });
    },
    methods: {
      add() {},
      search() {
        this.queryParams.startYear = this.dateRange[0];
        this.queryParams.endYear = this.dateRange[1];
        this.debounceGET();
      },
      getListApi() {
        console.log('getListApi');
      },
      handleEdit(index, row) {}
    }
  };
</script>

<style lang="scss" scoped>
  .map-mgt {
    width: 100%;
    height: 100%;
    .tbl-box {
      height: calc(100% - 90px);
    }
  }
</style> 